package com.caul.demo.hadoop.mapreduce.join;


import org.apache.hadoop.io.Writable;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

/**
 * Created by sdliang on 2018/4/9.
 */
public class JoinBean implements Writable {


    public static final int FILE_ORDER = 1;//订单
    public static final int FILE_PROFILE = 2; //档案

  private String usname="";
  private String uid="";
  private String age="";
  private String orderid="";
  private String partner="";
    private int type=0;


  public void set(String uid,String usname, String age, String partner,int type) {
    this.usname = usname;
    this.uid = uid;
    this.age = age;
    this.partner = partner;
      this.type = type;
  }
  public void set(String uid, String orderid,int type) {
    this.uid = uid;
    this.orderid = orderid;
      this.type = type;
  }

  public String getUsname() {
    return usname;
  }

  public void setUsname(String usname) {
    this.usname = usname;
  }

  public String getUid() {
    return uid;
  }

  public void setUid(String uid) {
    this.uid = uid;
  }

  public String getAge() {
    return age;
  }

  public void setAge(String age) {
    this.age = age;
  }

  public String getOrderid() {
    return orderid;
  }

  public void setOrderid(String orderid) {
    this.orderid = orderid;
  }

  public String getPartner() {
    return partner;
  }

  public void setPartner(String partner) {
    this.partner = partner;
  }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    @Override
  public void write(DataOutput out) throws IOException {
    out.writeUTF(this.uid);
    out.writeUTF(this.usname);
    out.writeUTF(this.age);
    out.writeUTF(this.partner);
    out.writeUTF(this.orderid);
      out.writeInt(this.type);
  }

  @Override
  public void readFields(DataInput in) throws IOException {
    this.uid = in.readUTF();
    this.usname = in.readUTF();
    this.age = in.readUTF();
    this.partner = in.readUTF();
    this.orderid = in.readUTF();
      this.type = in.readInt();
  }

  public JoinBean clone(){
      JoinBean bean = new JoinBean();
      bean.set(getUid(),getUsname(),getAge(),getPartner(),getType());
      bean.set(getUid(),getOrderid(),getType());
      return bean;
  }

  @Override
  public String toString() {
    return new StringBuilder(this.usname).append(" ").
            append(this.age).append(" ").
            append(this.partner).append(" ").
            append(this.orderid).toString();
  }
}
